import { cloudService } from './index'
import { IBudgetInfo } from '@/types/budget'

export const addBudgetApi = (budget: IBudgetInfo): Promise<any> =>
  cloudService({
    url: '/home-api/budget',
    method: 'post',
    data: budget
  })

export const updateBudgetApi = (id: number, budget: IBudgetInfo): Promise<any> =>
  cloudService({
    url: `/home-api/budget/${id}`,
    method: 'put',
    data: budget
  })

export const deleteBudgetApi = (id: number): Promise<any> =>
  cloudService({
    url: `/home-api/budget/${id}`,
    method: 'DELETE'
  })

export const queryBudgetApi = (category: string): Promise<any> =>
  cloudService({
    url: '/home-api/budget',
    method: 'get',
    params: { category }
  })

export const queryBudgetCategory = (): Promise<any> =>
  cloudService({
    url: '/home-api/budget/category',
    method: 'get'
  })

export const queryBudgetRankStats = (category: string): Promise<any> =>
  cloudService({
    url: '/home-api/budget/stats/rank',
    method: 'get',
    params: { category }
  })

export const queryBudgetProjectStats = (category: string): Promise<any> =>
  cloudService({
    url: '/home-api/budget/stats/project',
    method: 'get',
    params: { category }
  })
